package main

import (
	"fmt"
	"io/fs"
	"path/filepath"
)

func main() {
	files := 0
	err := filepath.Walk("D:/", func(path string, info fs.FileInfo, err error) error {
		if err != nil {
			fmt.Printf("访问 %q 失败: %v\n", path, err)
			return filepath.SkipDir
		}
		if info.IsDir() {
			fmt.Printf("目录: %s\n", path)
		} else {
			fmt.Printf("文件: %s (大小: %d bytes)\n", path, info.Size())
			files++
		}
		return nil
	})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(files)
}
